<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        /* 
        json格式的语法
        var p='{"属性名":"属性值","属性名":[{},{}],"属性名":{}}'
        */
       var p='{"name":"张三","age":10,"dog":{"dname":"小花"},"star":["z","x","y"],"friends":[{"fname":"w"},{"fname":"z"},{"fname":"y"}]}'
       //通过json.parse（）可以将一个json串转换为一个对象
       var person=JSON.parse(p)
       console.log(person)
       console.log(typeof person);
       console.log(person.friends[0].fname);
       //通过json.stringify()将一个对象转换为json串
       var p1=JSON.stringify(person)
       console.log(p1);
       

       
    </script>

</head>
<body>
    
</body>
</html>